<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 *  支付回调-日志
 */
class PaycallbackLog extends Model
{
    protected $table = 'pay_callback_log';

    /**
     * 添加记录
     */
    static function addRecord($channel = PayOrder::CHANNEL_WX, $outTradeNo = '', $detailPost = [])
    {
        $model = new self();
        $model->channel = $channel;
        $model->out_trade_no = $outTradeNo;
        $model->detail = is_string($detailPost) ? $detailPost : json_encode($detailPost);
        $model->flag = 1;
        return $model->saveOrFail() ? 1 : 0;
    }
}
